<!DOCTYPE html>


<html lang="zh-CN,en,default">
  

    <head>
      <meta charset="utf-8" />
       
      <meta name="keywords" content="阳小良,个人博客,程序猿,插画师,技术博客,人生感悟" />
       
      <meta name="description" content="不想做插画师的程序猿，不是好厨师" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>零基础-搭建个人博客7-自动部署 |  阳小良</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-tech/createBlogs/零基础-搭建个人博客7-自动部署"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  零基础-搭建个人博客7-自动部署
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2025/01/19/tech/createBlogs/%E9%9B%B6%E5%9F%BA%E7%A1%80-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A27-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/" class="article-date">
  <time datetime="2025-01-19T15:13:14.000Z" itemprop="datePublished">2025-01-19</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E8%B0%8B%E7%94%9F%E6%89%8B%E6%AE%B5/">谋生手段</a> / <a class="article-category-link" href="/categories/%E8%B0%8B%E7%94%9F%E6%89%8B%E6%AE%B5/%E9%9B%B6%E5%9F%BA%E7%A1%80/">零基础</a> / <a class="article-category-link" href="/categories/%E8%B0%8B%E7%94%9F%E6%89%8B%E6%AE%B5/%E9%9B%B6%E5%9F%BA%E7%A1%80/%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/">搭建个人博客</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">4 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="本篇目的"><a href="#本篇目的" class="headerlink" title="本篇目的"></a>本篇目的</h2><blockquote>
<p>持续的迭代和更新，每次处理完成后都需要反复的执行git的相关命令，有时候还有未知网络问题导致传输更新失败。所以想通过曲线救国，集成工具实现一步上传编辑处理后的静态网页文件。</p>
<p>PS：本文操作基于 IntelliJ IDEA 社区版本进行。</p>
</blockquote>
<h2 id="自动部署："><a href="#自动部署：" class="headerlink" title="自动部署："></a>自动部署：</h2><h3 id="1-文件夹关联代码仓库："><a href="#1-文件夹关联代码仓库：" class="headerlink" title="1.文件夹关联代码仓库："></a>1.文件夹关联代码仓库：</h3><blockquote>
<p>我们根据前文所讲的【<a target="_blank" rel="noopener" href="https://sid2656.life/2015/01/14/tech/createBlogs/%E9%9B%B6%E5%9F%BA%E7%A1%80-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A22-%E5%9F%BA%E7%A1%80%E7%8E%AF%E5%A2%83/">基础环境</a>】和【<a target="_blank" rel="noopener" href="https://sid2656.life/2015/01/15/tech/createBlogs/%E9%9B%B6%E5%9F%BA%E7%A1%80-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A23-%E5%8D%9A%E5%AE%A2%E7%8E%AF%E5%A2%83/">博客环境</a>】搭建篇，<br>我们可以做如下规划：</p>
<blockquote>
<ol>
<li>将喜欢的模板仓库fork到自己的仓库中，因为涉及到模板的部分内容调整，是没办法给予他人的仓库修改的。</li>
<li>将模板下拉到本地，并且与hexo本身的目录结构产生关联，将博客搭建过程中的修改全部记录下来。</li>
</ol>
</blockquote>
<p>具体的关联代码如下：git clone <a target="_blank" rel="noopener" href="https://github.com/user/xxxx.git">https://github.com/user/xxxx.git</a> localDir</p>
<p>我们可以看一下hexo项目本身会产生变动的几个文件夹：</p>
<p><img src="http://files.sid2656.space/tech/createBlogs/hexoDir.jpg" alt="hexo项目目录" title="hexo项目目录 hexo"></p>
<p>source：这个是你写文章的源码目录，后续的所有文章都在这里添加；</p>
<p>public：这个是服务启动后生成的静态页面&amp;资源文件的目录；这个也就是后续需要部署到github的pages服务中的全部文件；</p>
<p>themes：这个是hexo你依赖的主题模板，这个可以在hexo社区中找你自己喜欢的模板；</p>
<p>因此，我们需要三个仓库用于关联这三个目录；对应的关系如下：</p>
<blockquote>
<p>source：文章源码仓库，此仓库只关注文章内容；</p>
</blockquote>
<blockquote>
<p>themes：模板主题仓库，因为需要自己定制处理，所以不能依赖原始仓库，否则后续的调整会严重依赖本地，如果更换电脑环境和改动都需要重新搭建。</p>
</blockquote>
<blockquote>
<p>public：博客静态页面仓库，这个用于发布最终的博客html静态页面的仓库，也是用于给大家访问的仓库。</p>
</blockquote>
</blockquote>
<h3 id="2-一同处理多个仓库内容："><a href="#2-一同处理多个仓库内容：" class="headerlink" title="2.一同处理多个仓库内容："></a>2.一同处理多个仓库内容：</h3><blockquote>
<p>因为根据1.我们已经可以做到仓库拉取到本地了，并且通过修改本地内容再通过git指令可以推送至远程，完成了基本的关联操作。</p>
<p>而1中我们提到的多个仓库，需要我们分别创建，并建立与本地文件夹的关联。</p>
<p>所以，我们将全部仓库关联到本地的项目中，可以做如下操作：</p>
<blockquote>
<ol>
<li>初始化项目根目录。例如：hexo init root；然后进入到根目录</li>
<li>选择一个个人喜欢的模板，拉取到本地。例如：git clone <a target="_blank" rel="noopener" href="https://github.com/sid2656/hexo-theme-ayer.git">https://github.com/sid2656/hexo-theme-ayer.git</a> themes&#x2F;ayer</li>
<li>在自己的git创建一个博客文章仓库，并拉取到本地。例如：git clone <a target="_blank" rel="noopener" href="https://github.com/sid2656/sid2656.git">https://github.com/sid2656/sid2656.git</a> source</li>
<li>将后续编辑后，启动本地服务产生的静态页面绑定的我们最终的博客仓库。例如：<a target="_blank" rel="noopener" href="https://github.com/sid2656/sid2656.github.io.git">https://github.com/sid2656/sid2656.github.io.git</a> public</li>
<li>至此我们便可以在IDE中编写自己的文章啦，并且可以通过IDE一键批量提交。</li>
</ol>
</blockquote>
<p>具体的操作效果如下：</p>
<p><img src="http://files.sid2656.space/tech/createBlogs/git-push.jpg" alt="hexo项目目录" title="hexo项目目录 hexo"></p>
<p>选中三个文件夹，一起进行git提交：</p>
<p><img src="http://files.sid2656.space/tech/createBlogs/git-push2.jpg" alt="hexo项目目录" title="hexo项目目录 hexo"></p>
<p>这里我们选择commit and push；</p>
<p>PS：public中有生成的文件需要进行add操作！</p>
<p>至此，多仓库的关联和一键提交，也完成啦！</p>
</blockquote>
<h3 id="3-实现一件部署到github："><a href="#3-实现一件部署到github：" class="headerlink" title="3.实现一件部署到github："></a>3.实现一件部署到github：</h3><blockquote>
<p>推送数据到仓库，基本上隔十分钟左右就可以看见最新的文章内容了，当然因为我们部署的public文件夹的内容，你在调整了source内容后，千万别忘记了执行 hexo g，来生成静态文件，并将生成的文件推送至仓库。</p>
<p>理论上来说，我们完成上述1.和2.中的内容，就已经完成了自动部署内容了。</p>
<p>可因为不可抗的因素，导致我们基本上无法正常访问github，只能开vpn或者其他的代理方式来访问，这个是比较麻烦的，每次都有做绑定启动等流程，网络还不一定稳定，如果想稳定使用，基本上是需要付费的。</p>
<p>那有没有在搭建期间配置好基础内容，后续的迭代不用再链接github的方式呢？</p>
<p>当然有啦！</p>
<p>与github齐名的国内代码仓库是gitee，之前也提供过pages服务，后来不知道什么原因这个服务已经下了。</p>
<p>但是，gitee提供了另一个比较好用的服务叫：仓库镜像！（后续可能会收费 —_—！）这个可以将gitee上面的仓库内容同步到github，或者讲github的仓库内容同步到gitee上面。</p>
<p>所以，我们完全可以将上面提到的仓库都转移到gitee上面，然后只将需要提供pages服务的仓库同步到github上面。</p>
<p>这样一来，我们便可以在后续的运营过程中拍拖VPN啦！</p>
</blockquote>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/" rel="tag">hexo</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%B0%8B%E7%94%9F%E6%89%8B%E6%AE%B5/" rel="tag">谋生手段</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9B%B6%E5%9F%BA%E7%A1%80/" rel="tag">零基础</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2025/01/20/tech/createBlogs/%E9%9B%B6%E5%9F%BA%E7%A1%80-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A28-Cloudflare%E5%85%8D%E8%B4%B9%E8%A7%A3%E6%9E%90%E5%9F%9F%E5%90%8D%E5%88%B0githubPages/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            零基础-搭建个人博客8-Cloudflare免费解析域名到githubPages
          
        </div>
      </a>
    
    
      <a href="/2025/01/18/tech/createBlogs/%E9%9B%B6%E5%9F%BA%E7%A1%80-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A26-%E7%BC%96%E8%BE%91%E5%99%A8%E6%8E%A8%E8%8D%90/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">零基础-搭建个人博客6-编辑器</div>
      </a>
    
  </nav>

  
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2011-2025
        <i class="ri-heart-fill heart_icon"></i> 阿良
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
        <li>
          <a href="https://beian.miit.gov.cn/" target="_black" rel="nofollow">京ICP备14051636号-6</a>
        </li>
        
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="阳小良"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories/">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories/%E5%8E%9F%E8%91%97/">原著</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories/%E4%BA%94%E5%91%B3%E6%9D%82%E9%99%88/%E5%A4%A9%E6%B6%AF%E6%B5%B7%E8%A7%92/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories/%E8%B0%8B%E7%94%9F%E6%89%8B%E6%AE%B5/">技术</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories/%E6%8A%95%E8%B5%84%E8%87%AA%E5%B7%B1/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/">读书</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="https://hi.huitu.com/1145549/">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="https://space.bilibili.com/3546831053129882/channel/seriesdetail?sid=4562367&ctype=0">画廊</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2011/02/14/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->

<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>